package com.zzh.ssm.service.impl;

import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import com.zzh.ssm.mapper.ItemsMapper;
import com.zzh.ssm.mapper.ItemsMapperCustom;
import com.zzh.ssm.po.Items;
import com.zzh.ssm.po.ItemsCustom;
import com.zzh.ssm.po.ItemsQueryVo;
import com.zzh.ssm.service.ItemsService;

public class ItemsServiceImpl implements ItemsService {

	@Autowired // 自动注入
	private ItemsMapperCustom itemsMapperCutom;
	@Autowired
	private ItemsMapper itemsMapper;

	@Override
	public List<ItemsCustom> findItemsList(ItemsQueryVo itemsQueryVo) throws Exception {
		// 通过ItemsMapperCustom查询商品信息

		return itemsMapperCutom.findItemsList(itemsQueryVo);
	}

	@Override
	public ItemsCustom findItemsById(Integer id) throws Exception {
		Items items = itemsMapper.selectByPrimaryKey(id);

		ItemsCustom itemsCustom =null;
		if (items!=null){ 
			itemsCustom=  new ItemsCustom();
			BeanUtils.copyProperties(items, itemsCustom);
		} 
		
		return itemsCustom;
	}

	@Override
	public void updateItems(Integer id, ItemsCustom itemsCustom) throws Exception {
		// 添加业务校验，通常在service接口对挂件参数进行校验
		//校验id为空抛出异常 int -->Iinteger
		
		
		//更新商品信息
		itemsCustom.setId(id); //必须传入id 
		itemsMapper.updateByPrimaryKeyWithBLOBs(itemsCustom);
		
		
		
		
		

	}

}
